package Demo03;
/*        int a = 10;
        int b = 20;
      System.out.println(a>b);
*///        System.out.println(person01>person02);
/*
@Override
public int compareTo(Person o) {
        if(this.age>o.age) {
        return 1;
        } else if(this.age==o.age) {
        return 0;
        }
        else {
        return -1;
        }
        }*///        System.out.println(person01.compareTo(person02));

import java.util.Comparator;

public class Test {
    public static void main(String[] args) {
        Person person01 = new Person("张三",1,1);
        Person person02 = new Person("李四",2,2);
        System.out.println(new AgeComparator().compare(person01, person02));
        System.out.println(new HeightComparator().compare(person01, person02));
        System.out.println(new NameComparator().compare(person01, person02));
    }
}

class HeightComparator implements Comparator<Person> {
    @Override
    public int compare(Person o1, Person o2) {
        return o1.height-o2.height;
    }
}

class NameComparator implements Comparator<Person> {

    @Override
    public int compare(Person o1, Person o2) {
        return o1.name.compareTo(o2.name);
    }
}

class AgeComparator implements Comparator<Person> {
    @Override
    public int compare(Person o1, Person o2) {
        return o1.age-o2.age;
    }
}

class Person{
    public String name;
    public int age;
    public int height;
    public Person(String name, int age, int height) {
        this.name = name;
        this.age = age;
        this.height = height;
    }
}